﻿
@{
    ViewBag.Title = "体检医院管理";
    Layout = "~/Views/Shared/layoutCommon.cshtml";
}

<section class="content-header">
    <h1>
        体检医院管理
        <small></small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i>主页</a></li>
        <li class="active">体检医院管理</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header">
                    <div class="form-inline">
                        <div data-toggle="distpicker" class="form-group">
                            <label>所在地</label>
                            <select name="ProvinceID" id="ProvinceID" class="form-control"></select>
                            <select name="CityID" id="CityID" class="form-control"></select>
                        </div>
                        <div class="form-group">
                            <label>医院名称</label>
                            <input type="text" class="form-control" style="width:200px;" maxlength="20" id="name" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <button type="button" class="btn btn-success btn-sm" id="btnSearch">查找</button>
                        </div>
                        <div class="form-group">
                            <button type="button" class="btn btn-success btn-sm" id="btnAdd">添加医院</button>
                        </div>
                        <h3 class="box-title"></h3>
                    </div>
                </div>
                <div id="datatable">

                </div>
                <!-- /.box-header -->
                <div class="box-footer clearfix ">
                    <ul id="pagination" class="pagination pagination-sm no-margin pull-right"></ul>
                </div>
                <!-- /.box-body -->
                <!-- /.box -->
            </div>
        </div>
    </div>
</section>
@section scriptsBottom{
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnSearch").click(function () {
                pageIndex = 1;
                search();
            });
            //分类
            search();
            $("#btnAdd").click(function () {
                edit('添加体检医院');
            });
        });

        //页码
        var pageIndex = 1;
        //查询
        function search() {
            var data = {
                CityID: $("#CityID").val(),
                Name: $("#name").val(),
                rows: 10,
                page: pageIndex
            }
             $("#datatable").load('@Url.Action("HospitalPartialList", "BasicData")', data, function (data) {
                document.getElementById('datatable').innerHTML = data;
                //alert($("#dataView").data("count"));
                //分页显示
                $('#pagination').twbsPagination("destroy");
                $('#pagination').twbsPagination({
                    totalItems: $("#dataView").data("count"),
                    visiblePages: 10,
                    pageSize: 10,
                    startPage: parseInt(pageIndex),
                    onPageClick: function (event, page) {
                        pageIndex = page;
                        search();
                    }
                });
            })
        }

        //修改
        function edit(title, id) {
            var tl = title == '' ? '修改体检医院' : title;
            var url = '@Url.Action("HospitalEdit", "BasicData")'
            url += id ? "?id=" + id : "";
            BMCW.showTopLayer(tl, url, 630, 453);
        }

        //删除
        function del(id) {
            var url = '@Url.Action("HospitalLogicDelete","BasicData")';
            BMCW.DataConfirm("", function () {
                BMCW.ajax({
                    url: url,
                    type: "Post",
                    data: {
                        id: id
                    },
                    success: function (o) {
                        if (o.status == 0) {
                            BMCW.msg("删除成功", function () {
                                search();
                            });

                        } else {
                            BMCW.alert("删除失败");
                        }
                    }
                });
            })
        }


    </script>
}

